package com.yidu.t299.dao.ssk;
import com.yidu.t299.domain.ssk.ChargeFormulae;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @author 粟术康
 * @version 1.0
 * @description
 * @date:2023/3/11 20:48
 */
@Mapper
public interface ChargeFormulaeMapper {
    /**
     * 添加优惠信息
     * @param chargeFormulae 优惠对象
     * @return 影响的行数(返回1则为成功)
     */
    @Insert({"insert into charge_formulae (charge_formulae_id,preferential_item,discount,charge_formulae_remark)" +
            " values " +
            "(#{chargeFormulaeId,jdbcType=INTEGER}, " +
            "#{preferentialItem,jdbcType=VARCHAR},"+
            "#{discount,jdbcType=VARCHAR},"+
            "#{chargeFormulaeRemark,jdbcType=VARCHAR})"
    })
    int insert(ChargeFormulae chargeFormulae);
    /**
     * 根据优惠编号删除该优惠信息
     * @param chargeFormulaeId 优惠编号
     * @return 影响的行数(返回1则为成功)
     */
    @Delete({"delete from charge_formulae" +
            " where charge_formulae_id = #{chargeFormulaeId,jdbcType=INTEGER}"})
    int deleteByPrimaryKey(Integer chargeFormulaeId);
    /**
     * 根据优惠信息修改其数据
     * @param chargeFormulae 优惠对象
     * @return 影响的行数(返回1则为成功)
     */
    @Update({
            "update charge_formulae" +
                    " set preferential_item = #{preferentialItem,jdbcType=VARCHAR}," +
                    "discount = #{discount,jdbcType=VARCHAR}," +
                    "charge_formulae_remark = #{chargeFormulaeRemark,jdbcType=VARCHAR}"+
            " where charge_formulae_id = #{chargeFormulaeId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ChargeFormulae chargeFormulae);
    /**
     * 根据优惠编号查询指定的信息
     * @param chargeFormulaeId 优惠编号
     * @return 优惠对象
     */
    @Select({
            "select" +
                    " charge_formulae_id,preferential_item,discount,charge_formulae_remark" +
                    " from charge_formulae" +
                    " where charge_formulae_id = #{chargeFormulaeId,jdbcType=INTEGER}"
    })
    @Results(id = "ChargeFormulaeMap",value = {
            @Result(id = true,column = "charge_formulae_id",property = "chargeFormulaeId" ),
            @Result(column = "preferential_item",property = "preferentialItem"),
            @Result(column = "discount",property = "discount"),
            @Result(column = "charge_formulae_remark",property = "chargeFormulaeRemark")
    })

    ChargeFormulae selectByPrimaryKey(Integer chargeFormulaeId);

    /**
     * 按条件分页查询优惠数据集合
     * @param rows 每页的行数
     * @param page 页码
     * @param condition 条件参数
     * @return 优惠对象集合
     */
    @Select("select * from charge_formulae where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("ChargeFormulaeMap")
    List<ChargeFormulae> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    /**
     * 按条件查询chargeFormulae表中数据行数
     * @param condition 条件参数
     * @return 数据行数
     */
    @Select("select count(*) from charge_formulae where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);
}
